<template>
	<view>
		<view class="mainpadding flexbetween">
			<view class="titletext xiaohei fonweight" @click="save()">取消</view>
			<view class="titletext xiaolv fonweight" @click="save(1)">保存</view>
		</view>
		<view class="shuox mainpadding margin_top">
			<input type="text" placeholder="请输入你的昵称" v-model="nickname">
		</view>
		<view class="mainpadding2">
			<view class="flexleft">
				<view class="titletext xiaohong fonweight">*</view>
				<view class="ershil xiaohui nofonweight">限10字以内，超过字数输入无效</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				nickname:"",
			}
		},
		onLoad(opt) {
			this.nickname = opt.name
		},
		methods: {
			save(val){
				if(val==1){
					if(this.nickname==""){
						httpRequest.toast("请输入昵称")
						return false
					}
					if(this.nickname.length>10){
						httpRequest.toast("名称过长！")
						return false
					}
					uni.$emit("editname",this.nickname)
				}
				uni.navigateBack(1)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.shuox {
		background: #F5F5F5;
	}
</style>